

let addMid = (req, res, next) => {
  // 接受is_show参数并进行校验
  let { is_show } = req.body;
  // 不为空校验  
  if (!is_show) return next({ code: 2, message: '参数is_show必须传递' });

  // 正则校验  
  if (!/^(1|0)$/.test(is_show)) return next({ code: 3, message: '参数is_show格式错误' });

  next();
}

let rmMid = (req, res, next) => {
  // 接受name参数并进行校验
  let { name } = req.query;
  // 不为空校验  
  if (!name) return next({ code: 2, message: '参数name必须传递' });
  next();
}

let listMid = (req, res, next) => {
  // 接受is_show参数并进行校验
  let { is_show } = req.query;
  if (is_show && is_show != 1) return next({ code: 2, message: '参数is_show只能是1' });
  next();
}

module.exports = {
  addMid, rmMid, listMid
}